/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author TuanAnh
 */
@Entity
@Table(name = "ReservationBill")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ReservationBill.findAll", query = "SELECT r FROM ReservationBill r"),
    @NamedQuery(name = "ReservationBill.findByResbillId", query = "SELECT r FROM ReservationBill r WHERE r.resbillId = :resbillId"),
    @NamedQuery(name = "ReservationBill.findByDateCome", query = "SELECT r FROM ReservationBill r WHERE r.dateCome = :dateCome"),
    @NamedQuery(name = "ReservationBill.findByDateOut", query = "SELECT r FROM ReservationBill r WHERE r.dateOut = :dateOut"),
    @NamedQuery(name = "ReservationBill.findByNumberPeople", query = "SELECT r FROM ReservationBill r WHERE r.numberPeople = :numberPeople")})
public class ReservationBill implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "resbillId")
    private String resbillId;
    @Column(name = "dateCome")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateCome;
    @Size(max = 10)
    @Column(name = "dateOut")
    private String dateOut;
    @Column(name = "numberPeople")
    private Integer numberPeople;
    @JoinTable(name = "ReservationDetail", joinColumns = {
        @JoinColumn(name = "resbillId", referencedColumnName = "resbillId")}, inverseJoinColumns = {
        @JoinColumn(name = "roomId", referencedColumnName = "roomID")})
    @ManyToMany
    private Collection<Room> roomCollection;
    @JoinColumn(name = "customerId", referencedColumnName = "customerId")
    @ManyToOne
    private Customer customerId;

    public ReservationBill() {
    }

    public ReservationBill(String resbillId) {
        this.resbillId = resbillId;
    }

    public String getResbillId() {
        return resbillId;
    }

    public void setResbillId(String resbillId) {
        this.resbillId = resbillId;
    }

    public Date getDateCome() {
        return dateCome;
    }

    public void setDateCome(Date dateCome) {
        this.dateCome = dateCome;
    }

    public String getDateOut() {
        return dateOut;
    }

    public void setDateOut(String dateOut) {
        this.dateOut = dateOut;
    }

    public Integer getNumberPeople() {
        return numberPeople;
    }

    public void setNumberPeople(Integer numberPeople) {
        this.numberPeople = numberPeople;
    }

    @XmlTransient
    public Collection<Room> getRoomCollection() {
        return roomCollection;
    }

    public void setRoomCollection(Collection<Room> roomCollection) {
        this.roomCollection = roomCollection;
    }

    public Customer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Customer customerId) {
        this.customerId = customerId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (resbillId != null ? resbillId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ReservationBill)) {
            return false;
        }
        ReservationBill other = (ReservationBill) object;
        if ((this.resbillId == null && other.resbillId != null) || (this.resbillId != null && !this.resbillId.equals(other.resbillId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.fpt.entity.ReservationBill[ resbillId=" + resbillId + " ]";
    }
    
}
